<template>
  <div>
    {{ name }}
    <el-input v-model="val"></el-input>
    <el-button @click="notifyTwo">通知兄弟</el-button>
    <el-button @click="notifyTwoOnce">只通知兄弟</el-button>
  </div>
</template>
<script>
export default {
  props: {
    name: {
      type: String,
    },
  },
  data() {
    return {
      val: "",
    };
  },
  created() {
    console.log("my-child:" + this.name);
  },
  mounted() {
    console.log("my-child:" + this.name);
  },
  methods: {
    notifyTwo() {
      this.EventBus.emit("nofityTwo", this.val);
    },
    notifyTwoOnce() {
      this.EventBus.once("nofityTwoOnce", this.val);
    },
  },
  destoryed() {
    console.log("my-child destoryed");
  },
};
</script>
